<?php
	include("includes/secure.php");
	include("includes/config.php");
	include("includes/class/empresarial_dependiente.class.php");
	
	$empresarial_dependiente = new Empresarial_dependiente(); 
	$company =  $empresarial_dependiente->companyList();
	$employed = $empresarial_dependiente->empleadoList();
	$parameter = $empresarial_dependiente->parameterList();
	$dateValue = date("d/m/Y");
	
	$eps_code = $hdv_code  = 0;
		
	$where_employed = "";
	
	$employed3			= '';
	$employed4			= '';
	
	$getNumber = $empresarial_dependiente->getNumberReceipt();
	$getNumber= $getNumber+1;
	$emde_code = 0;
	$emde_receipt = cerosIzquierda($getNumber);	

	$msg_info = $msg_alert = $msg_error = false;
	$_SESSION['msg_cool'] = '';
	$show_msg = 0;
			
	if(isset($_POST['addEmpresarialDependiente']) && $_POST['addEmpresarialDependiente'] == 1){
		$action = $_POST["action"];
		$numero = $_POST['input_eps']; 
		$data->emde_letras = num2letras($numero);
		$data->emde_receipt = $emde_receipt;
		$data->emde_date_periodo = cambiarFormatoFecha($dateValue,2);
		$data->emde_periodo = cambiarFormatoFecha($_POST['emde_periodo'],7);
		$data->hdvc_code = trim(mysql_real_escape_string($_POST['hdvc_code']));
		$data->emde_company_name = trim(mysql_real_escape_string($_POST['emde_company_name']));
		$data->emde_company_nit = trim(mysql_real_escape_string($_POST['emde_company_nit']));
		$data->emde_company_address = trim(mysql_real_escape_string($_POST['emde_company_address']));
		$data->emde_reingreso = trim(mysql_real_escape_string($_POST['emde_reingreso']));
		$data->emde_otros = trim(mysql_real_escape_string($_POST['emde_otros']));
		$data->emde_ajuste  = trim(mysql_real_escape_string($_POST['emde_ajuste']));
		$data->emde_admin = $_POST["emde_admin"];
		$data->emde_admin_iva = $_POST["emde_admin_iva"];
		$data->emde_value_admission = $_POST["emde_value_admission"];
		$data->emde_funeral = $_POST["emde_funeral"];
		$data->emde_name_eps = $_POST["emde_name_eps"];
		$data->emde_value_eps = $_POST["emde_value_eps"];
		$data->emde_name_arp = $_POST["emde_name_arp"];
		$data->emde_value_arp = $_POST["emde_value_arp"];
		$data->emde_name_afp = $_POST["emde_name_afp"];
		$data->emde_value_afp = $_POST["emde_value_afp"];
		
		$data->emde_name_sena = $_POST["emde_name_sena"];
		$data->emde_value_sena = $_POST["emde_value_sena"];
		$data->emde_name_icbf = $_POST["emde_name_icbf"];
		$data->emde_value_icbf = $_POST["emde_value_icbf"];
		$data->emde_name_caja = $_POST["emde_name_caja"];
		$data->emde_value_caja = $_POST["emde_value_caja"];

		$data->emde_reingreso = $_POST["emde_reingreso"];
		$data->emde_aporte_mutual = $_POST["emde_aporte_mutual"];
		$data->emde_otros = $_POST["emde_otros"];
		$data->emde_ajuste = $_POST["emde_ajuste"];
		$data->emde_interes_mora = $_POST["emde_interes_mora"];
		$data->emde_descuentos = $_POST["emde_descuentos"];
		$data->emde_recibido = $_SESSION['use_name'].' '.$_SESSION['use_lastname'];
		$data->emde_total = trim(mysql_real_escape_string($_POST['input_eps']));
		

		if ($empresarial_dependiente->addEmpresarialDependiente($data)){
			$msg_info = true;
				$_SESSION["msg_cool"] .= 'Se adiciono el recibo satisfactoriamente..!!!<br />';
			echo "<script> window.location.href='listEmpresarialDependiente.php?show_msg=2'</script>";
		}
		else{
			$msg_error = true;
				$_SESSION["msg_cool"] .= 'No pudo ser adicionado el recibo... Sorry..!!!<br />';
			echo "<script> window.location.href='listEmpresarialDependiente.php?show_msg=1'</script>";
		}
	}
	
	if ( $msg_error )
		$show_msg = 1;
	elseif ( $msg_alert )
		$show_msg = 2;
	elseif ( $msg_info )
		$show_msg = 3;	
		

?>